package
{
	import flash.display.MovieClip;
	import flash.events.Event;

	public class grafic extends MovieClip
	{
		public var Width,Height : int;
		public var oX,oY : Number;
		private var scalare : Number;
		public var unitate : Number;
		
		public function grafic()
		{
			this.addEventListener(Event.ADDED_TO_STAGE,initializare);
		}
		
		private function initializare(e:Event):void
		{
			Width=stage.stageWidth-150;
			Height=stage.stageHeight-100;
			
			oX = Width/2;
			oY = Height/2;
			
			unitate = 10;
			scalare = 1;
			
			deseneaza();
		}
		
		public function set setUnitate(unit:Number):void
		{
			unitate=unit;
			
			deseneaza();
		}
		
		private function deseneaza():void
		{
			graphics.clear();
			
			graphics.beginFill(CONST.fundalGrafic,1);
			graphics.drawRoundRect(0,0,Width,Height,5,5);
			
			graphics.lineStyle(1,CONST.linieGrafic);
			
			graphics.moveTo(0,oY);
			graphics.lineTo(Width,oY);
			graphics.moveTo(oX,0);
			graphics.lineTo(oX,Height);
			
			graphics.moveTo(oX-3,3);
			graphics.lineTo(oX,0);
			graphics.moveTo(oX+3,3);
			graphics.lineTo(oX,0);
			
			graphics.moveTo(Width-3,oY-3);
			graphics.lineTo(Width,oY);
			graphics.moveTo(Width-3,oY+3);
			graphics.lineTo(Width,oY);
			
			var i : Number;
			for(i = oX;i <= Width;i += unitate)
			{
				graphics.moveTo(i,oY-scalare);
				graphics.lineTo(i,oY+scalare);
			}
			for(i = oX;i >=0 ;i -= unitate)
			{
				graphics.moveTo(i,oY-scalare);
				graphics.lineTo(i,oY+scalare);
			}
			
			for(i = oY;i <= Height;i += unitate)
			{
				graphics.moveTo(oX-scalare,i);
				graphics.lineTo(oX+scalare,i);
			}
			for(i = oY;i >= 0;i -= unitate)
			{
				graphics.moveTo(oX-scalare,i);
				graphics.lineTo(oX+scalare,i);
			}
		}
	}
}